package com.imonsoft.sqm.service;

import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.stereotype.Service;

@Service("messageUtil")
public class MessageUtil implements MessageSourceAware {

	private MessageSourceAccessor messages;

	public String getMessage(String code, Object[] args, String defaultMessage) {
		return messages.getMessage(code, args, defaultMessage);
	}

	public String getMessage(String code, Object[] args) {
		return messages.getMessage(code, args);
	}

	public String getMessage(String code) {
		return messages.getMessage(code);
	}

	@Override
	public void setMessageSource(MessageSource arg0) {
		this.messages = new MessageSourceAccessor(arg0);
	}

}
